<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="客户名称" prop="clientName">
        <el-input v-model="queryParams.clientName" placeholder="请输入客户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户型号" prop="customerModel">
        <el-input v-model="queryParams.customerModel" placeholder="请输入客户型号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="销售订单号" prop="clientOrderNumber">
        <el-input v-model="queryParams.clientOrderNumber" placeholder="请输入销售订单号" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="产品名称" prop="orderNumber">
        <el-input v-model="queryParams.orderNumber" placeholder="请输入产品名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户下单日期" prop="clinentOrderDate">
        <el-date-picker clearable v-model="queryParams.clinentOrderDate" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择客户下单日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="颜色" prop="colour">
        <el-select v-model="queryParams.colour" filterable placeholder="请选择颜色" clearable>
          <el-option v-for="dict in dict.type.colour" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="ticketsList">
      <el-table-column label="销售订单号" align="center" prop="clientOrderNumber" />
      <el-table-column label="客户下单日期" align="center" prop="clinentOrderDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.clinentOrderDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="生产工单号" align="center" prop="ticketsId" />
      <el-table-column label="客户名称" align="center" prop="clientName" />
      <el-table-column label="产品编码" align="center" prop="productId" />
      <el-table-column label="产品名称" align="center" prop="productName" />
      <el-table-column label="规格型号" align="center" prop="specifications" />
      <el-table-column label="客户型号" align="center" prop="customerModel" />
      <el-table-column label="颜色" align="center" prop="colour">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.colour" :value="scope.row.colour" />
        </template>
      </el-table-column>
      <el-table-column label="计划数量" align="center" prop="plannedQuantity" />
      <el-table-column label="包装数量" align="center" prop="quantityPacked" />
      <el-table-column label="入库数量" align="center" prop="quantityStorage" />
      <el-table-column label="出库数量" align="center" prop="returnNumber" />
      <el-table-column label="结存数量" align="center" prop="balanceQuantity" />
      <el-table-column label="生产线" align="center" prop="productLine">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.product_line" :value="scope.row.productLine" />
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />


  </div>
</template>

<script>
import { listTickets } from "@/api/storage/tickets/tickets";
export default {
  name: "customerSchedule",
  dicts: ['colour', 'product_line'],
  data() {
    return {
      //测试时间
      value1: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产工单表格数据
      ticketsList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNumber: null,
        billData: null,
        clientName: null,
        clientOrderNumber: null,
        clinentOrderDate: null,
        colour: null,
        warehouse: null,
        scheduledStartTime: null,
        pctime: null,
        audit: null,
        close: null,
        productId: null,
        productName: null,
        specifications: null,
        customerModel: null,
        cartonSize: null
      },
      // 表单参数
      form: {},

      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询生产工单列表 */
    getList() {
      this.loading = true;
      listTickets(this.queryParams).then(response => {
        this.ticketsList = response.rows;
        this.total = response.total;
        console.log(this.ticketsList);
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        ticketsId: null,
        orderNumber: null,
        billData: null,
        clientName: null,
        clientOrderNumber: null,
        clinentOrderDate: null,
        colour: null,
        warehouse: null,
        productLine: null,
        scheduledStartTime: null,
        pctime: null,
        plannedQuantity: null,
        quantityPacked: null,
        quantityPackedNostored: null,
        quantityStorage: null,
        remark: null,
        audit: null,
        close: null,
        delFlag: null,
        productId: null,
        productName: null,
        specifications: null,
        customerModel: null,
        cartonSize: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
